// 文章管理
import {request} from '../utils/request'
// const ARTICLE_URL = 'http://dev.content.lbs.p.yufeiworld.com/'
// const ARTICLE_URL = 'http://dev.gateway.lbs.p.yufeiworld.com'
const ARTICLE_URL = ''

export type ARTICLE_ACTION = {
	action: number,
	id: string, // 文章id
	behavior: number,
	comment: string
}
// 文章点赞，访问，收藏
export const requestArticleAction = (articleAction : Partial<ARTICLE_ACTION>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/action`,
		method: "POST",
		data: articleAction,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}

// 文章点赞，收藏， 评论行为收集
export const requestArticleBehavior = (articleBehavior : Partial<ARTICLE_ACTION>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/behavior`,
		method: "POST",
		data: articleBehavior,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}

// 删除文章
export const requestArticleDelete = (delId : {id: number}) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/delete`,
		method: "POST",
		data: delId,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}
// // 文章详情
// export const requestArticleDetail = (detailData : {id: number}) => {
// 	return request({
// 		url: ARTICLE_URL + `/admin/content/article/get`,
// 		method: "GET",
// 		data: detailData,
// 		header: {
// 			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
// 		}
// 	})
// }
// 文章详情
export const requestArticleDetail = (id: number) => {

	return request({
		url: ARTICLE_URL + `/admin/content/article/getInfo/${id}`,
		method: "GET",
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}

export type ARTICLE_Label = {
	activityId: number,
	articleCategoryId: number,
	articleStatus: Array<number>,
	articleTitle: string,
	latitude: string,
	longitude: string,
	page: number,
	pageSize: number,
	source: number,
	type: number,
	updateEndTime: string,
	updateStartTime: string
}
// 文章标签
export const requestArticleGetArticleLabel = (detailLabel: Partial<ARTICLE_Label>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/getArticleLabel`,
		method: "GET",
		data: detailLabel,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}


export type BehaviorList = {
	page: number,
	pageSize: number
}
// 获取登录用户点赞，评论，收藏行为
export const requestArticleGetBehaviorList = (behaviorList : any) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/getBehaviorList`,
		method: "GET",
		data: behaviorList,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}

export type ARTICLE_INFO = {
	accessCount: number,
	activityId: number,
	activityWord: string,
	articleCategoryId: number,
	articleCover: string,
	articleDetail: string,
	articleDigest: string,
	articleLabel: string,
	articleMainPic: string,
	articleStatus: Array<number>,
	articleTitle: string,
	favoriteCount: number,
	id: string,
	latitude: string,
	likeCount: number,
	longitude: string,
	shopId: number,
	areaId: number,
	source: number
}
// 新增文章
export const requestArticleInsert = (articleInfo : Partial<ARTICLE_INFO>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/insert`,
		method: "POST",
		data: articleInfo,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}


export type ARTICLE_TYPE = {
	activityId: number,
	articleCategoryId: number,
	articleStatus: Array<number>,
	articleTitle: string,
	latitude: string,
	longitude: string,
	page: number,
	pageSize: number,
	source: number,
	updateEndTime: string,
	updateStartTime: string,
	online:number,
	areaId:number,
	userId:number
}
// 获取文章列表
export const requestArticleList = (articleDetail : Pick<ARTICLE_TYPE, 'latitude' | 'longitude' | 'page' | 'pageSize' | 'source'>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/list`,
		method: "GET",
		data: articleDetail,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}
// 根据城市ID获取文章列表
export const requestArticleListByAreaId = (articleDetail : Pick<ARTICLE_TYPE, 'latitude' | 'longitude' | 'page' | 'pageSize' | 'source' | 'areaId' >) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/getListByAreaId`,
		method: "GET",
		data: articleDetail,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}
// 更新文章
export const requestArticleUpdate = (articleInfo : Partial<ARTICLE_INFO>) => {
	return request({
		url: ARTICLE_URL + `/admin/content/article/update`,
		method: "POST",
		data: articleInfo,
		header: {
			'content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
		}
	})
}